package ${package}.${moduleName}.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.source.common.page.ConventPage;
import com.source.common.page.PageOutput;

import ${package}.${moduleName}.entity.${ClassName};
import ${package}.${moduleName}.query.${ClassName}Query;
import ${package}.${moduleName}.mapper.${ClassName}Mapper;
import ${package}.${moduleName}.service.${ClassName}Service;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * ${tableComment}
 *
 * @author ${author} ${email}
 * @since ${version} ${date}
 */
@Service
public class ${ClassName}ServiceImpl extends ServiceImpl<${ClassName}Mapper, ${ClassName}> implements ${ClassName}Service {

    /**
     * 获取所有数据列表，并分页
     *
     * @param query 查询对象
     * @return ResponsePage<${ClassName}>
     */
    @Override
    public PageOutput<${ClassName}> get${ClassName}AndPage(${ClassName}Query query) {
        IPage<${ClassName}> ${className}Page = baseMapper.selectPage(ConventPage.getPage(query), getQw(query));
        return ConventPage.getPageOutput(${className}Page);
     }

    /**
    * 获取所有数据列表，不分页
    *
    * @param query 查询对象
    * @return List<${ClassName}>
    */
    @Override
    public List<${ClassName}> get${ClassName}s(${ClassName}Query query) {
        return this.list(getQw(query));
    }

    /**
    * 构建Mybatis-Plus的查询条件对象。
    *
    * @param query 查询对象
    * @return LambdaQueryWrapper<${ClassName}>
    */
    private LambdaQueryWrapper<${ClassName}> getQw(${ClassName}Query query){
        if(query != null) {
            LambdaQueryWrapper<${ClassName}> wrapper = new LambdaQueryWrapper<${ClassName}>();
            return wrapper;
        }
        return Wrappers.lambdaQuery();
    }

}